<?php

require_once '../../config.php';

$messages = messages_get($_GET['sessionId']);
$play = false;

if (messages_check_new_outgoing($_GET['sessionId'])) {
  $play = true;
  messages_mark_outgoing_as_read($_GET['sessionId']);
}

?>

<?php foreach($messages as $m): ?>
  <div style="padding:5px;border: 1px solid #ccc; border-width: 0px 0px 1px 0px">
    <?php echo $m['senderName'] . ': ' . $m['message'] ?>
  </div>
<?php endforeach ?>

<?php if ($play): ?>
  <embed src="/sound/message.wav" autostart="true" loop="false" volume="100" hidden="true" /><noembed><bgsound src="file.wav"></noembed>
<?php endif ?>